import requests
from requests import utils

url = 'http://127.0.0.1:8787/dar/user/login'
data = {
    "user_name": "test01",
    "passwd": "admin123"
}
#--------------post-------------
res = requests.post(url=url,data=data)
# #返回文本  ""为字符串
# print(res.text)
# #返回json  ''为json类型
# print(res.json())
#-----------get--------------

url_2 = 'http://127.0.0.1:8787/coupApply/cms/goodsList'
h = {"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"}
data_2 = {
    "msgType": "getHandsetListOfCust",
    "page": 1,
    "size": 20
}
res_2 = requests.get(url=url_2,params=data_2,headers=h)
# print(res_2.text)
# print(res_2.json())

#--------requests.session()---------
#保持登录状态
sess = requests.session()
res_3 = sess.request(method="post",url=url,data=data)
# print(res_3.json())

#----------cookie-----------
#获取接口的cookie
res_4 = sess.request(method='post',url=url,data=data)
#获取cookie
cookie = requests.utils.dict_from_cookiejar(res_4.cookies)
print(cookie)